package simple14;

import simple14.discount.*;
import simple14.factory.AppleFactory;
import simple14.factory.BananaFactory;
import simple14.factory.OrangeFactory;
import simple14.fruit.Fruit;
import simple14.template.OnLineShopping;
import simple14.template.ShoppingCart;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链模式
 */
public class Simple {

    private static MultyDiscount multyDiscount = new FullDiscount(null);

    static {
        multyDiscount = new NewerDiscount(multyDiscount);
        multyDiscount = new SecondDiscount(multyDiscount);
        multyDiscount = new HolidayDiscount(multyDiscount);
    }

    public static void main(String[] args) {
        List<Fruit> products = new ArrayList<>();
        products.add(new AppleFactory().getFruit());
        products.add(new OrangeFactory().getFruit());
        products.add(new BananaFactory().getFruit());
        ShoppingCart cart = new OnLineShopping(products);
//        优惠政策
//        cart.setDiscount(new FullDiscount());
        cart.setDiscount(multyDiscount);
        cart.submitOrder();
    }
}
